$(function () {
    let data=myAjax("/home","","get");
    setCompany(data.companyModel);
    setNavigation(data.findNavigation);
    setNavigations(data.findNavigation);
    setProduct(data.productFind);
    setProductsFind(data.productsFind);
    setProductsFinds(data.productsFind);
    setNewsFind(data.newsFind);
})

//所有新闻查询
function setNewsFind(data) {
    let html='';
    for(let i=0; i<4; i++){
        html +='<div>\n' +
            '                <div>\n' +
            '                    <p></p>\n' +
            '                    <p>'+data[i].date+'</p>\n' +
            '                </div>\n' +
            '                <div>\n' +
            '                    <p class="navigation" onclick="selectNewsById('+data[i].id+')">'+data[i].title+'</p>\n' +
            '                    <p> '+data[i].content+'</p>\n' +
            '                </div>\n' +
            '            </div>';
    }
    $('#newsFind').html(html);
}


function selectNewsById(id) {
    window.open("newsDetailed.html","_self");
    localStorage.setItem("NewsId",id);
}


//工程案例查询
function setProductsFind(data) {
    let html='';
    let titlea='';
    for (let i=0; i<4; i++){
        html +='<img onclick="selectProductById('+data[i].id+')" id="productsimg" src="'+data[i].imgHref+'"/>';
        titlea +='<div>'+data[i].title+'</div>';
    }
    $("#imga").html(html);
    $("#titlea").html(titlea);
}


//工程案例查询
function setProductsFinds(data) {
    let html='';
    let titlea='';
    for (let i=4; i<8; i++){
        html +='<img onclick="selectProductById('+data[i].id+')" id="productsimg" src="'+data[i].imgHref+'"/>';
        titlea +='<div>'+data[i].title+'</div>';
    }
    $("#imgb").html(html);
    $("#titleb").html(titlea);
}


function selectProductById(id) {
    window.open("engineeringDetailed.html","_self");
    localStorage.setItem("productId",id);
}


//工程类型查询
function setProduct(data) {
    console.log(data);
    let html='';
    for (let i=0; i<data.length; i++){
        html +='<div class="navigation" onclick="reqProducts('+data[i].id+')">\n' +
            '            <div class="productLogo"><img src="'+data[i].imgHref+'"/></div>\n' +
            '            <div><p>'+data[i].casetypename+'</p></div>\n' +
            '            <div><p>'+data[i].content+'</p></div>\n' +
            '        </div>';
    }
    $("#productFind").html(html);
}

function reqProducts(id){
    localStorage.setItem("typeFindid",id);
    window.open('engineering.html','_self');
}

//top导航信息查询
function setNavigation(data) {
    let html='';
    for (let i=0; i<data.length; i++){
        if (data[i].isShow!="隐藏") {
            html +='<div class="navigationColor"><p><a href="'+data[i].connection+'">'+data[i].name+'</a></p></div>';
        }
            }
    html +='        <div class="input">\n' +
        '            <div><input type="text" placeholder="请输入"></div>\n' +
        '            <div><img src="../img/fdj1.png"/></div>\n' +
        '        </div>';
    $('#navigation').html(html);
}


//foot导航信息查询
function setNavigations(data) {
    let html='';
    for (let i=0; i<data.length; i++){
        if (data[i].isShow!="隐藏") {
            html += '<div><p><a href="' + data[i].connection + '">' + data[i].name + '</a></p></div>';
        }
    }
    $('#navigations').html(html);
}


//公司信息
function setCompany(data) {
    let logo='<img src="'+data.logo+'"/>';
    let email=data.email;
    let landline=data.landline;
    let address=data.address;
    let tel=data.tel;
    let phone=data.phone;
    let hotline=data.hotline;
    $("#companyLogo").html(logo);
    $("#email").text(email);
    $("#emails").text(email);
    $("#landline").text(landline);
    $("#address").text(address);
    $("#tel").text(tel);
    $("#phone").text(phone);
    $("#hotline").text(hotline);
}